﻿@model IEnumerable<PrjctMngmt.Models.Project>

@{
    ViewBag.Title = "Projects";
    var odd = false;
}

@*
<script type="text/javascript">
    $(function () {
        $("#milestone").dialog({
            autoOpen: false, width: 400, modal: true,
            buttons: {
                "Save": function () {
                    $.post("/Milestone/Create",
                        $("#MilestoneForm").serialize(),
                        function () {
                            $("#milestone").dialog("close");
                            window.location.reload();
                        });
                },
                Cancel: function () { $(this).dialog("close"); }
            }
        });
        $(".addMilestone").click(function () {
            $("#milestone").html("")
                .dialog("option", "title", "Create milestone")
                .load("/Milestone/Create", function () { $("#milestone").dialog("open"); });
        });
    });
</script>
*@

<h2>Projects</h2>

<p>
    @Html.ActionLink("Add new project", "Create")
    <br />
    @Html.ActionLink("Add project assignment", "Create", "ProjectAssignment")
    <br />
    @Html.ActionLink("Add new milestone", "Create", "Milestone")
</p>

@if (Model.Count() > 0)
{
    <div class="datagrid">
        <table>
            <thead>
                <tr>
                    <th>
                        Name
                    </th>
                    <th>
                        Status
                    </th>
                </tr>
            </thead>
            @foreach (var item in Model)
            {
                <tbody>
                    <tr class="@(odd ? "alt" : "")">
                        <td>
                            @Html.ActionLink(item.Name, "Details", new { id = item.ProjectID })
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Status)
                        </td>
                    </tr>
                    @{ odd = !odd; }
                </tbody>
            }
        </table>
    </div>
}
else
{
    <p>
        No projects found.
    </p>
}

@*
<div id="milestone"></div>
*@